Object.defineProperty(exports, "__esModule", {
    value: !0
});

var e = require("../../utils/config"), t = require("../../utils/storage"), r = require("../../utils/self-selected-order"), i = require("../../utils/request"), o = require("../../utils/api"), a = require("../../utils/map-convert");

Component({
    properties: {
        marginTop: {
            type: String,
            value: "0px"
        }
    },
    data: {
        list: [],
        themeColor: getApp().globalData.themeColor,
        reservationOrderImageUrl: "",
        selfSelectedOrderImageUrl: "",
        filmPrintOrderImageUrl: "",
        privacyContractName: "",
        showPrivacy: !1
    },
    lifetimes: {
        attached: function() {
            this.setData({
                reservationOrderImageUrl: e.resourceRoot + "yydd.png?v=1",
                selfSelectedOrderImageUrl: e.resourceRoot + "xszd.png",
                filmPrintOrderImageUrl: e.resourceRoot + "jpsq.png"
            });
        },
        detached: function() {},
        ready: function() {}
    },
    methods: {
        openPrivacyContract: function() {
            wx.openPrivacyContract({
                fail: function() {
                    wx.showToast({
                        title: "遇到错误",
                        icon: "error"
                    });
                }
            });
        },
        exitMiniProgram: function() {
            this.setData({
                showPrivacy: !1
            });
        },
        handleAgreePrivacyAuthorization: function() {
            this.setData({
                showPrivacy: !1
            });
        },
        onBindClick: function(e) {
            if (t.isLogin()) {
                if ("1" == e.currentTarget.id && wx.navigateTo({
                    url: "/pages/my-reservation-order/my-reservation-order"
                }), "2" == e.currentTarget.id) {
                    var r = this;
                    wx.getPrivacySetting({
                        success: function(e) {
                            if (e.needAuthorization) r.setData({
                                privacyContractName: e.privacyContractName,
                                showPrivacy: !0
                            }); else {
                                var i = t.getStorageSync(t.storageKey.cityInfo), o = t.getStorageSync(t.storageKey.locationInfo);
                                null != i && null != i && "" != i && null != o && null != o && "" != o ? r.goselfSelectedOrderList() : wx.getLocation({
                                    type: "gcj02",
                                    success: function(e) {
                                        console.log("自选项目列表，微信获取的位置信息", e);
                                        var i = a.qqMapToBMap(e.longitude, e.latitude);
                                        t.setStorageSync(t.storageKey.locationInfo, {
                                            expireTimestamp: new Date().getTime() + 6e5,
                                            latitude: i[1].toString(),
                                            longitude: i[0].toString()
                                        }), r.selectCityByCoordinates(i[1].toString(), i[0].toString());
                                    },
                                    fail: function(e) {
                                        console.log("微信获取位置信息失败：" + e.errMsg), e.errMsg.indexOf("频繁") > -1 ? console.log("请勿频繁定位") : wx.showModal({
                                            title: "提示",
                                            content: "请点击小程序右上角“···”，设置中允许使用位置信息，并重新进入小程序",
                                            showCancel: !1
                                        });
                                    }
                                });
                            }
                        }
                    });
                }
                "3" == e.currentTarget.id && wx.navigateTo({
                    url: "/pages/film-print-list/film-print-list"
                });
            } else {
                if ("1" == e.currentTarget.id && wx.navigateTo({
                    url: "/pages/authorize/authorize?path=reservation"
                }), "2" == e.currentTarget.id) {
                    var i = this;
                    wx.getPrivacySetting({
                        success: function(e) {
                            e.needAuthorization ? i.setData({
                                privacyContractName: e.privacyContractName,
                                showPrivacy: !0
                            }) : wx.navigateTo({
                                url: "/pages/authorize/authorize?path=selfSelectedOrderList"
                            });
                        }
                    });
                }
                "3" == e.currentTarget.id && wx.navigateTo({
                    url: "/pages/authorize/authorize?path=filmPrintList"
                });
            }
        },
        selectCityByCoordinates: function(e, r) {
            var a = this, n = o.apiRoute.selectCityByCoordinates + "?latitude=" + e + "&longitude=" + r;
            i.request(i.HttpMethod.GET, n, {}).then(function(e) {
                if (e.success) {
                    var r = e.data.filter(function(e) {
                        return "1" == e.deep;
                    });
                    if (null != r && null != r && r.length > 0) {
                        var i = r[0].id + "00", o = r[0].name;
                        a.setData({
                            city: o,
                            cityCode: i
                        }), t.setStorageSync(t.storageKey.cityInfo, {
                            city: o,
                            cityCode: i
                        }), a.goselfSelectedOrderList();
                    }
                }
            });
        },
        goselfSelectedOrderList: function() {
            var i = t.getStorageSync(t.storageKey.cityInfo), o = t.getStorageSync(t.storageKey.locationInfo);
            r.getJwt().then(function(t) {
                if (t.success) {
                    var r = t.data.token, a = "".concat(e.selfSelectedOrderUrl, "order_list?token=").concat(r, "&cityCode=").concat(null == i.cityCode ? "310100" : i.cityCode);
                    null != o && null != o && "" != o && (a += "&latitude=".concat(o.latitude, "&longitude=").concat(o.longitude)), 
                    console.log("跳转线上组单列表地址：" + a), wx.navigateTo({
                        url: "/pages/webview/webview?h5=".concat(encodeURIComponent(a)),
                        success: function() {}
                    });
                }
            });
        }
    }
});